# from django import forms
# from django.core.exceptions import ValidationError
# import pdb
# from user.models import VSession, FileStore, Company, WarZone
# from software.models import SoftwareType, Software, SoftwareVersion
# from storehouse.models import Storehouse
#
#
# def token_check(value):
#     # 验证token必须存在
#     sessionList = VSession.objects.filter(token=value)
#     if not sessionList.exists():
#         errMsg = 'token Error'
#         raise ValidationError(errMsg)
#     else:
#         session = sessionList[0]
#
#
# # 文件检查
# def file_check(value):
#     # 验证token必须存在
#     file = FileStore.objects.filter(pk=value)
#     if not file.exists():
#         errMsg = 'fileId Error'
#         raise ValidationError(errMsg)
#     else:
#         session = file[0]
#
#
# def softwareType_check(value):
#     # 验证token必须存在
#     softwareType = SoftwareType.objects.filter(pk=value)
#     if not softwareType.exists():
#         errMsg = 'softwareType Error'
#         raise ValidationError(errMsg)
#     else:
#         session = softwareType[0]
#
#
# def company_check(value):
#     # 验证token必须存在
#     company = Company.objects.filter(pk=value)
#     if not company.exists():
#         errMsg = 'company Error'
#         raise ValidationError(errMsg)
#     else:
#         session = company[0]
#
#
# def warZone_check(value):
#     # 验证token必须存在
#     warZone = WarZone.objects.filter(pk=value)
#     if not warZone.exists():
#         errMsg = 'warZone Error'
#         raise ValidationError(errMsg)
#     else:
#         session = warZone[0]
#
#
# def software_check(value):
#     # 验证token必须存在
#     software = Software.objects.filter(pk=value)
#     if not software.exists():
#         errMsg = 'software Error'
#         raise ValidationError(errMsg)
#     else:
#         session = software[0]
#
#
# def storeHouse_check(value):
#     # 验证token必须存在
#     store = Storehouse.objects.filter(pk=value)
#     if not store.exists():
#         errMsg = 'store Error'
#         raise ValidationError(errMsg)
#     else:
#         session = store[0]
#
#
# class UploadSoftForm(forms.Form):
#     token = forms.CharField(max_length=100, validators=[token_check])
#     softwareName = forms.CharField(max_length=20)
#     cost = forms.CharField(max_length=20)
#     store = forms.CharField(max_length=20, validators=[storeHouse_check])
#     softwareDetails = forms.CharField(max_length=20)
#     version = forms.CharField(max_length=20)
#     warZone = forms.CharField(max_length=20, validators=[warZone_check])
#     company = forms.CharField(max_length=20, validators=[company_check])
#     softwareType = forms.CharField(max_length=20, validators=[softwareType_check])
#     logo = forms.CharField(max_length=20, validators=[file_check])
#     cover = forms.CharField(max_length=20, validators=[file_check])
#     verification = forms.CharField(max_length=20, validators=[file_check])
#     software = forms.CharField(max_length=20, validators=[file_check])
#     material = forms.CharField(max_length=20, validators=[file_check])
#
#     def clean_version(self):
#         version = self.cleaned_data['version']
#         if "as" in version:
#             raise ValidationError("You have forgotten about Fred!")
#         return version
#
#
# class UploadForm(forms.Form):
#     token = forms.CharField(max_length=100, validators=[token_check])
#     file = forms.FileField(required=False)
#
#
# class UpdateSoftForm(forms.Form):
#     token = forms.CharField(max_length=100, validators=[token_check])
#     softwareId = forms.CharField(max_length=20, validators=[software_check])
#     version = forms.CharField(max_length=20)
#     updateDetails = forms.CharField(max_length=5000)
#     soft = forms.CharField(max_length=20, validators=[file_check])
